SwiftExtract: fix private(set) being ignored for variables with explicit accessors - #908
Merged
ktoso merged 1 commit intoSep 5, 2026
Conversation
…cit accessors supportedAccessorKinds(binding:minimumAccessLevel:) returned on the accessor block before it checked the private(set) modifier, so a variable that both restricts its setter's access level and spells out its accessors got a setter binding emitted for an inaccessible setter.
Contributor
Author
|
@ktoso thanks for the review, lmk if anything else is needed here |
ktoso
approved these changes
Sep 5, 2026
Collaborator
|
Thank you, will include this in the 0.6.0 now :) |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #535.
supportedAccessorKinds(binding:minimumAccessLevel:)returned early onbinding.accessorBlockbefore it reached theprivate(set)check, so a variable that bothrestricts its setter's access level and spells out its accessors explicitly got a setter
binding emitted for a setter it cannot call:
Moving the modifier check above the accessor block fixes it. The existing
variable_int_privateSettest already coverspublic private(set) varwithout an accessorblock, which is why this only shows up when the accessors are written out; the new test
covers that case.
swift testpasses, 670 tests in 89 suites. The new test fails before the change and passesafter it.
Not changed here
Subscripts have the same problem by a different path.
SwiftAnalysisVisitor.visit(subscriptDecl:)calls the no-argument
accessorBlock.supportedAccessorKinds(), which never consultsminimumAccessLevel, sopublic private(set) subscriptstill emits a$setbinding. I keptthis PR to the variable case. Happy to fold the subscript fix in here or open a separate
issue for it, whichever you prefer.